package cz.apnetis.fitweb.shared;

/** Result which come when user save something to database
 * @author Lukas "benzin" Benda <a href="mailto:bendal@apnet.cz">bendal@apnet.cz</a>
 * @since Sep 29, 2010
 */
public class SaveResult {

  /** Flag which inform if save is successful */
  private final boolean successful; public final boolean getSuccessful() { return successful; }
  /** Key of saved entity */
  private final String key; public final String getKey() { return key; }
  /** Unsuccessful message */
  private final String unsuccessfulMessage; public final String getUnsuccessfulMessage() { return unsuccessfulMessage; }

  /** Construction for successful save */
  public SaveResult(String newKey) {
    this.successful = true;
    this.key = newKey;
    this.unsuccessfulMessage = null;
  }

  /** Construction for unsuccessful save */
  public SaveResult(String newKey, String newUnsuccessfulMessage) {
    this.successful = false;
    this.key = newKey;
    this.unsuccessfulMessage = newUnsuccessfulMessage;
  }
}
